<template>
  <div>
    <!-- 输入框 -->
    <van-cell-group>
      <van-field
        v-model="password"
        placeholder="输入注册密码：包含大写字母，小写字母，数字三种"
        autofocus
      />
    </van-cell-group>
    <!-- 登录按钮 -->
    <div class="bottom">
      <van-button
        round
        type="info"
        size="large"
        :disabled="flag"
        @click="toRegister"
        color="linear-gradient(to right, #ff6034, #ee0a24)"
      >
        注册
      </van-button>
    </div>
  </div>
</template>

<script>
import { dofinishregister } from "../../api/user";
export default {
  data() {
    return {
      password: "",
      // flag: true,
    };
  },
  computed: {
    flag() {
      if (
        /^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])\S*$/.test(
          this.password
        )
      ) {
        return false;
      } else {
        return true;
      }
    },
  },
  methods: {
    toRegister() {
      dofinishregister({
        tel: localStorage.getItem("tel"),
        password: this.password,
      }).then(() => {
        // console.log(res);
        this.$router.go(-3);
      });
    },
  },
};
</script>

<style scoped>
.bottom {
  width: 85%;
  margin: 10px auto;
}
</style>